package com.visec.hdy.hadoop.storage;

import java.io.IOException;

import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.log4j.Logger;

import com.visec.hdy.hadoop.standard.FSB;

/**
 * 定制:hdfs数据存储实现类
 * 
 * @author hdy
 *
 * @param <K>
 * @param <V>
 */
public class HdfsLogStorageImpl<K, V> extends JsonLogStorageImpl<K, V> {

	private final Logger log = Logger.getLogger(HdfsLogStorageImpl.class);

	public HdfsLogStorageImpl(FSB fsb) {
		super(fsb);
	}

	@Override
	public void flush() {
		try {
			if (outputStream == null || writer == null)
				return;
			if (outputStream instanceof FSDataOutputStream) {
				writer.flush();
				((FSDataOutputStream) outputStream).hflush();
			} else {
				writer.flush();
			}
		} catch (IOException e) {
			log.error("", e);
		}
	}

}
